package com.lili.operate.service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lili.model.operate.MessageSign;
import com.lili.operate.mapper.MessageSignMapper;
import com.lili.operate.service.MessageSignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageSignServiceImpl implements MessageSignService {

    @Autowired
    MessageSignMapper messageSignMapper;

    @Override
    public int deleteSign(long id) {
        return messageSignMapper.deleteSign(id);
    }

    /**
     * 根据id来更新数据
     * @param messageSign
     * @return
     */
    @Override
    public int updateSign(MessageSign messageSign) {
        QueryWrapper<MessageSign> wrapper = new QueryWrapper<>();
        wrapper.eq("id",messageSign.getId());
        messageSignMapper.update(messageSign,wrapper);
        return 0;
    }


    /**
     * 保存签名信息
     * @param messageSign
     * @return
     */
    @Override
    public int saveMessageSign(MessageSign messageSign) {
        return messageSignMapper.insert(messageSign);
    }

    /**
     * 分页查询所有签名
     * @param current
     * @param size
     * @return
     */
    @Override
    public Page<MessageSign> queryByPage(int current, int size) {
        Page<MessageSign> page = new Page<>(current,size);
        QueryWrapper<MessageSign> wrapper = new QueryWrapper<>();
        wrapper.eq("isdel",0);
        messageSignMapper.selectPage(page,wrapper);
        return page;
    }
}
